package logic

import (
	"context"
	"fmt"
	"hr_srv/models"

	"hr_srv/hr_srv"
	"hr_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PushJobLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPushJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushJobLogic {
	return &PushJobLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PushJobLogic) PushJob(in *hr_srv.PushJobRequest) (*hr_srv.PushJobResponse, error) {
	// todo: add your logic here and delete this line
	job := models.Job{
		UserId:      in.UserId,
		JobName:     in.JobName,
		JobClass:    in.JobClass,
		WorkAddress: in.WorkAddress,
		JobTips:     in.JobTips,
		LowPrice:    in.LowPrice,
		TopPrice:    in.TopPrice,
		WorkTIme:    in.WorkTime,
		DegRee:      in.DegRee,
		JobDes:      in.JobDes,
	}
	if models.DB.Create(&job).Error != nil {
		return &hr_srv.PushJobResponse{}, fmt.Errorf("服务器繁忙")
	}
	return &hr_srv.PushJobResponse{}, nil
}
